import '@babel/polyfill'
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Axios from 'axios'
import Print from 'vue-print-nb'
import Antd, {message, notification} from 'ant-design-vue'
import "./assets/fonts/iconfont.css";
import global from './api/global.js'
Vue.prototype.global = global
import {
    Input,
    Table,
	Pagination,
    TableColumn,
    Button,
    ButtonGroup,
    Tag,
    Autocomplete,
    Dialog,
    Loading,
    Select,
    Option,
    Upload,
    Avatar
} from 'element-ui'
import 'ant-design-vue/dist/antd.less'
import './utils/filter'
import tool from './utils/tool'
import '@/styles/nprogress.css'
import './permission'

Vue.config.productionTip = false

Vue.use(Avatar)
Vue.use(Upload)
Vue.use(Select)
Vue.use(Option)
Vue.use(tool)
Vue.use(Input)
Vue.use(Table)
Vue.use(Pagination)
Vue.use(TableColumn)
Vue.use(Button)
Vue.use(ButtonGroup)
Vue.use(Tag)
Vue.use(Autocomplete)
Vue.use(Dialog)
Vue.use(Loading.directive)
Vue.use(Antd)
message.config({
    maxCount: 1
})
notification.config({
    placement: 'topRight',
    duration: 3
})

Vue.use(Print);  //注册

Vue.prototype.$ajax = Axios


// 根据路由设置标题
router.beforeEach((to, from, next) => {
  /*路由发生改变修改页面的title */
  if(to.meta.title) {
    document.title = to.meta.title
  }
  next()
})

function registerComponents() {
    const components = require.context('@/components/', true, /index\.(js|vue)$/)
    components.keys().forEach(key => {
        const name = key.match(/\w+/)[0]
        const component = process.env === 'production' ? components(key) : components(key).default
        Vue.component(name, component)
    })
}
window.Promise = Promise;
// 在开发环境中开启Devtools工具
Vue.config.devtools = process.env.NODE_ENV === 'development'
// 在浏览器开发工具的性能/时间线面板中启用性能追踪
Vue.config.performance = process.env.NODE_ENV === 'development'

registerComponents()
new Vue({
    router,   
    store,
    render: h => h(App)
}).$mount('#app')

